﻿using System;

namespace NNCore
{
	class DefaultNetLoader : NetLoader
	{
		public NN loadNN()
		{
			NN nn = new NN();
			nn.Layers = createLayer();

			return nn;
		}

		private Layer[] createLayer()
		{
			Layer[] newLayers = new Layer[3];
			newLayers[0] = new Layer();
			newLayers[0].WeightMatrix = null;
			newLayers[1] = new Layer();
			newLayers[1].WeightMatrix = new Matrix(64, 42);
			newLayers[2] = new Layer();
			newLayers[2].WeightMatrix = new Matrix(42, 1);

			SetupLayer(newLayers[0], null, new Identity());
			SetupLayer(newLayers[1], new Tanh(), new Identity());
			SetupLayer(newLayers[2], null, new Identity());
			return newLayers;
		}

		public void SetupLayer(Layer layer, AFunction activationFunction, AFunction outputFunction)
		{
			if (layer.WeightMatrix != null)
			{

				layer.ActivationFunction = activationFunction;
				double[] threshold = new double[layer.WeightMatrix.Width];

				layer.Threshold = threshold;
			}
			else
			{
				double[] threshold = new double[64];


				layer.Threshold = threshold;
			}

			layer.OutputFunction = outputFunction;
		}

		public void saveNN(NN saveMe)
		{
			throw new NotImplementedException();
		}
	}
}
